
#include "zos_config.h"


#ifdef BOARD_USING_ADC_DEMO
#include  "zos.h"

/**
 * @brief 任务线程
 */
int demo_adc(int argc, char *argv[])
{
	zos_uint32_t i;
    /*接收到的参数小于3个*/
    if (argc < 2)
    {
        zos_printf("Usage: demo_adc channel\r\n");
        zos_printf("Like: demo_adc 0   read ADC0\r\n");
		zos_printf("Like: demo_adc 1   read VBAT\r\n");
        return ZOS_ERROR;
    }

    /*转换输入的channel*/
    i = strtoul(argv[1], 0, 10);

	/*如果输入的channel是0或者1，开始读取并打印，如果输入错误，进行错误提示*/
	if(i == 0 || i == 1)
	{
		if(i == 0)
		{
			zos_printf("[demo_adc] adc0 read is: %dmV\r\n ",zos_adc_read(ZOS_ADC_BUS_0));
		}
		else
		{
			zos_printf("[demo_adc] vbat read is: %dmV \r\n",zos_adc_read(ZOS_ADC_BUS_VBAT));
		}
		return ZOS_EOK;
	}
	zos_printf("[demo_adc] channel error!!!\r\n");
    zos_printf("Like: demo_adc 0   read ADC0\r\n");
	zos_printf("Like: demo_adc 1   read VBAT\r\n");
	return ZOS_ERROR;
}

#include "shell.h"

SHELL_EXPORT_CMD(demo_adc,demo_adc, adc demo);


#endif //DEMO_TEST
